<!DOCTYPE html>
<html lang="zh">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>平面转换-渐变</title>
  <style>
    * {
      margin: 0;
      padding: 0;
      box-sizing: border-box;
    }

    .box {
      margin: 100px auto;
      position: relative;
      width: 416px;
      height: 240px;
    }

    .box img {
      width: 100%;
      height: 100%;
    }

    .mask {
      position: absolute;
      top: 0;
      width: 100%;
      height: 100%;
      /* 线性渐变 半透明 */
      background-image: linear-gradient(transparent, rgba(0, 0, 0, .5));
      opacity: 0;
      transition: all .5s;
    }

    .box:hover .mask {
      cursor: pointer;
      opacity: 1;
    }
  </style>
</head>

<body>
  <div class="box">
    <img src="../../素材/images/dog1.webp" alt="">
    <div class="mask"></div>
  </div>
</body>

</html>